package org.example.consumer;

import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Java8Consumer2 {
    public static void main(String[] args) {
        List<Integer> list = IntStream.range(1,6).boxed().collect(Collectors.toList());
        Consumer<Integer> consumer = System.err::println;
        forEach(list,consumer);
        forEach(list, System.err::println);

    }
    static <T>  void forEach(List<T> list,Consumer<T> consumer){
        for (T t : list) {
            consumer.accept(t);
        }
    }
}
